<?php
/**
 * @Author: xuzhiyi
 * @Date:   2016-02-16 20:57:17
 * @Last Modified by:   xuzhiyi
 * @Last Modified time: 2016-03-01 02:48:50
 * ------------------------------------------------ *
 * 会员级别                                          *
 * ------------------------------------------------ */
namespace Admin\Model;

 
class UserRanksModel extends CommonModel{

	/* 添加级别
	 *--------------------------*/
	 public function addUserRanks(){
		$data = array();
		$data["rankName"] = I("rankName");
		$data["startScore"] = I("startScore");
		$data["endScore"] = I("endScore");
		$data["rebate"] = I("rebate");
		$data["createTime"] = date('Y-m-h H:i:s');
	    if($this->checkEmpty($data)){
			$u = M('user_ranks');
			$rs = $u->add($data);
			if(false !== $rs){
				return true;
			}
		}
		return false;
	}

	//删除级别
	 public function delUserRanks(){
	 	$rankId = (int)I('rankId');
	 	$a = M('user_ranks');
	    $rs = $a->where("rankId=".$rankId)->delete();;
		if(false !== $rs){
			return true;
		}
		return false;
	 }

	 
	 /* 修改级别
	 *--------------------------*/
	 public function editUserRanks(){
	 	$rankId = (int)I("rankId",0);
		$data = array();
		$data["rankName"] = I("rankName");
		$data["startScore"] = I("startScore");
		$data["endScore"] = I("endScore");
		$data["rebate"] = I("rebate");

	    if($this->checkEmpty($data)){
			$rs = M('user_ranks')->where("rankId=".$rankId)->save($data);
			if(false !== $rs){
				return true;
			}
		}
		return false;
	}
    
}